import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/login'
import Layout from '@/views/layout'

Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    redirect: '/login'

  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  //首页
  {
    path: '/home',
    component: Layout,
 
    children: [
      {
        path: '',
        component: () => import("@/views/home")

      },

    ]
  },
  // 医院综合
  {
    path: '/hospital',
    component: Layout,
    redirect: '/hospital/management',
    meta:{title:"医院综合"},
    children: [
      {
        path: '/hospital/management',
        meta:{title:"科室管理"},
        component: () => import("@/views/GeneralHospital/management.vue")

      }, {
        meta:{title:"添加科室"},
        path: '/hospital/add',
        component: () => import("@/views/GeneralHospital/addManagement.vue")
      }

    ]
  },
  // 患者大数据
  {
    path: '/patient',
    component: Layout,
    redirect: '/patient/illness',
    meta:{title:"患者大数据"},
    children: [
      {
        path: '/patient/illness',
        meta:{title:"疾病大数据"},
        component: () => import("@/views/patient/illness.vue")

      }, {
        meta:{title:"药品耗材统计"},
        path: '/patient/consumable',
        component: () => import("@/views/patient/consumable.vue")
      }

    ]
  },
  // 动态个人
  {
    path: '/circle',
    component: Layout,
    redirect: '/circle/circle',
    meta:{title:"动态个人"},
    children: [
      {
        path: '/circle/circle',
        meta:{title:"挂号管理"},
        component: () => import("@/views/circle")

      }

    ]
  },
  // 中西药房
  {
    path: '/western',
    component: Layout,
    redirect: '/western/revenue',
    meta:{title:"中西医药房"},
    children: [
      {
        path: '/western/management',
        meta:{title:"处方综合管理"},
        component: () => import("@/views/ChineseWestern/management.vue")

      }, {
        path: '/western/revenue',
        meta:{title:"营收数据表"},
        component: () => import("@/views/ChineseWestern/revenue.vue")
      }

    ]
  },
  // 医疗前线
  {
    path: '/medical',
    component: Layout,
    redirect: '/medical/issue',
    meta:{title:"医疗前线"},
    children: [
      {
        path: '/medical/issue',
        meta:{title:"处方开具"},
        component: () => import("@/views/medical/issue.vue")

      }, {
        path: '/medical/prescriptionmanagement',
        meta:{title:"处方综合管理"},
        component: () => import("@/views/medical/PrescriptionManagement.vue")
      }

    ]
  },
  //药品出去库
  {
    path: '/hangout',
    component: Layout,
    redirect: '/hangout/SupplyManagement',
    meta:{title:"医疗药物出去库"},
    children: [
      {
        path: '/hangout/AddMedicine',
        meta:{title:"添加药品耗材"},
        component: () => import("@/views/hangOut/AddMedicine.vue")

      }, {
        path: '/hangout/SupplyManagement',
        meta:{title:"医疗用品综合管理"},
        component: () => import("@/views/hangOut/SupplyManagement.vue")
      }

    ]

  },
  // 分级护士
  {
    path: '/nurse',
    component: Layout,
    redirect: '/nurse/list',
    meta:{title:"分级护士"},
    children: [
      {
        path: '/nurse/edit',
        meta:{title:"修改个人信息"},
        component: () => import("@/views/nurse/edit.vue")

      }, {
        path: '/nurse/list',
        meta:{title:"综合列表"},
        component: () => import("@/views/nurse/list.vue")
      }, {
        path: '/nurse/Workforce',
        meta:{title:"排班管理"},
        component: () => import("@/views/nurse/Workforce.vue")
      }

    ]

  },
  // 
  // 分级医生
  {
    path: '/doctor',
    component: Layout,
    redirect: '/doctor/list',
    meta:{title:"分级医生"},
    children: [
      {
        path: '/doctor/edit',
        meta:{title:"修改个人信息"},
        component: () => import("@/views/doctor/edit.vue")

      }, {
        path: '/doctor/list',
        meta:{title:"综合列表"},
        component: () => import("@/views/doctor/list.vue")
      }, {
        path: '/doctor/Workforce',
        meta:{title:"排班管理"},
        component: () => import("@/views/doctor/Workforce.vue")
      }

    ]

  },
  // 病床管理
  {
    path: '/bed',
    component: Layout,
    redirect: '/bed/index',
    meta:{title:"病床管理"},
    children: [
      {
        path: '/bed/index',
        meta:{title:"综合管理"},
        component: () => import("@/views/bed")

      }, {
        path: '/bed/add',
        meta:{title:"添加床位"},
        component: () => import("@/views/bed/add.vue")
      }

    ]
  },
  // 全账号管理
  {
    path: '/account',
    component: Layout,
    redirect: '/account/list',
    meta:{title:"全账号管理"},
    children: [
      {
        path: '/account/list',
        meta:{title:"账号管理"},
        component: () => import("@/views/account/list.vue")

      }, {
        path: '/account/add',
        meta:{title:"添加账号"},
        component: () => import("@/views/account/add.vue")
      }

    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
